# -*- coding: utf-8 -*-
'''
@author: Donny
@Created on: 2011-8-24
@version: 2011.8.24
@summary: unit test of ExcelOperator class
'''
import unittest
from util.xmlparse import XmlParser
from util.util import Util
from action.step import Step

class XmlParser_Test(unittest.TestCase):
    '''
    XmlParser method unit test.
    '''        
    def setUp(self):
        '''
        Set up test data.
        '''
        print 'xmlparse_test -- setUp '
        self.root = Util.get_root_path()
    
    def tearDown(self):
        '''
        Tear down test.
        '''
        print 'xmlparse_test -- tearDown '
        self.xml_parser = None
        
    def test_read_case_from_xml(self):
        '''
        Test read_case_from_xml method.
        '''
        print 'reporter_test -- test_read_case_from_xml '
        self.xml_parser = XmlParser(self.root + "\\Cases\\case.xml")
        case_list = self.xml_parser.read_case_from_xml()
        print 'reporter_test -- test_read_case_from_xml: case_list = ' \
              + str(case_list)
              
    def test_write_xml_report(self):
        '''
        Test write_xml_report method.
        '''
        print 'reporter_test -- test_write_xml_report '
        self.xml_parser = XmlParser(self.root + \
                                    "\\Results\\123456_results.xml")
        single_result_list = ['123456', False, Step('1', '2', '3', '4', '5')]
        self.xml_parser.write_xml_report(single_result_list)
        print 'reporter_test -- test_write_xml_report: single_result_list = ' \
              + str(single_result_list)
        
    def test_read_xml_report(self):
        '''
        Test read_xml_report method.
        '''
        print 'reporter_test -- test_read_xml_report '
        self.xml_parser = XmlParser(self.root + \
                                    "\\Results\\123456_results.xml")
        result_list = self.xml_parser.read_xml_report()
        print 'reporter_test -- test_read_xml_report: result_list = ' \
              + str(result_list)
        
        
if __name__ == "__main__":
#    unittest.main()
    suite = unittest.TestSuite()
    suite.addTest(Reporter_Test("test_read_xml_report"))
    unittest.TextTestRunner().run(suite)
